package com.example.config;

import com.example.utils.TimeFilter2;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

import javax.servlet.Filter;

/**
 * @Author: 马宇航
 * @Todo: 这个对象是用来把第二个过滤器注册到spring中
 * @DateTime: 22/02/15/0015 上午 11:24
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class FiterRegisterBean {
    @Bean
    public FilterRegistrationBean<TimeFilter2> timeFilters2(){
        FilterRegistrationBean<TimeFilter2> filters = new FilterRegistrationBean<>();
        //把我们的过滤器放入系统的过滤器注册器中
        filters.setFilter(new TimeFilter2());
        //设计过滤器拦截的请求
        filters.addUrlPatterns("/*");
//        设置过滤器的优先级
        filters.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filters;
    }
}
